This file should be read only once, so another check is done on the existence of one of the commands defined there.
A new group is started to keep the definition of the macro \format
,
which is used in the following if statement, local. When the current format
turns out to be plain TEX the file latexhax.sty has to be read. But the
definitions in that file should remain valid after the group is closed. This
could be accomplished by making all definitions global, but another
solution is to tell TEX to process the file latexhax.sty after
the current group has been closed. The command \aftergroup
puts the next
token on a list to be processed after the group.